#!/usr/bin/expect -f


#项目名称
set projectName lwyapi

set tmpProjectName lwyapitmp

#项目路径
set projectPath /usr/local/docker_pack/lwyapi
# 设置ssh连接的用户名
set user root

# 设置ssh连接的host地址
set host 192.168.11.19

# 设置ssh连接的登录密码
set password cgm123


#将本地压缩包拷贝的远端
#spawn scp ./tmp.tar.gz $user@$host:$projectPath
#expect "*password:"
#send "$password\r"


#登录远端
spawn ssh $user@$host

#输入密码
expect "*password:"
send "$password\r"

#进入远端项目目录
#expect "]*"
#send "cd $projectPath && mkdir $tmpProjectName && cd $tmpProjectName && mv $projectPath/tmp.tar.gz ./ \r"
#
##解压包
#expect "]*"
#send "tar mxzf tmp.tar.gz && rm -f ./tmp.tar.gz;\r"
#
##
###拷贝文件到当前目录
#expect "]*"
#send "rm -rf $projectPath/$projectName && mv $projectPath/$tmpProjectName $projectPath/$projectName\r"
#
#
##打包应用
#expect "]*"
#send "cd $projectPath  && ./build-docker.sh \r"

#重启
expect "]*"
send "cd /home/docker-lwy  && ./start-compose.sh \r"

#退出
expect "]*"
send "exit\r"

# 控制权移交
interact